export default {
    loggedIn(state,data){
        localStorage.setItem('user',JSON.stringify(data))
        state.auth = {status:'loggedIn',user:data}

    },
    logout(state){
        console.log('LOGOUT')
        localStorage.removeItem('user')
        state.auth = {status:'',user: null}
    },
    initAuth(state){
        const user = JSON.parse(localStorage.getItem('user'))
        if(user){
            state.auth = {status:'loggedIn',user:user}
        }
    },
    replaceEmp(state,emp){
        let idx = state.employees.findIndex(e=>e.emp_id==emp.emp_id)
        state.employees.splice(idx,1,emp)
    },
    deleteEmp(state,emp_id){
        let idx = state.employees.findIndex(e=>e.emp_id==emp_id)
        state.employees.splice(idx,1)
    },
    getData(state,paged_data){
        state.employees = paged_data
        state.loading = false
    }
}